package com.example.bpmn.listener;

import com.example.bpmn.event.ProcessEvent;
import com.example.bpmn.service.ProcessCallbackService;
import com.example.bpmn.service.ProcessEventPublisher;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.RuntimeService;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class ProcessMessageListener {
    private final RuntimeService runtimeService;
    private final ProcessCallbackService callbackService;
    private final ProcessEventPublisher eventPublisher;

    @KafkaListener(topics = "process-events", groupId = "bpmn-process-group")
    public void handleProcessEvent(ProcessEvent event) {
        log.info("收到流程事件: eventName={}, businessKey={}", 
            event.getEventName(), event.getBusinessKey());
            
        try {
            // TODO: 实现消息处理逻辑
        } catch (Exception e) {
            log.error("处理流程事件失败", e);
        }
    }
} 